package com.example.demo.pipeline;

import com.example.demo.data.Wap;
import com.example.demo.data.WapRepository;
import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.pipeline.Pipeline;

import javax.annotation.Resource;
import java.util.Map;

public class MyPipeline implements Pipeline{
    @Resource
    WapRepository wapRepository;

	@Override
	public void process(ResultItems resultItems, Task task) {
		Map<String, Object> all = resultItems.getAll();
		for (String key : all.keySet()) {
			Wap wap = (Wap) all.get(key);
            System.out.println(wap);
            wapRepository.save(wap);
		}
	}

}
